<?
// Start the session since phpFlickr uses it but does not start it itself
session_start();

// Require the phpFlickr API
require_once('phpFlickr.php');

// Create new phpFlickr object: new phpFlickr('[API Key]','[API Secret]')
$flickr = new phpFlickr('2e4e72a03aa4db503bfe128e4b4b20e6','7a7efe62bce5d84e', true);

// Authenticate;  need the "IF" statement or an infinite redirect will occur
if(empty($_GET['frob'])) {
	$flickr->auth('write'); // redirects if none; write access to upload a photo
}
else {
	// Get the FROB token, refresh the page;  without a refresh, there will be "Invalid FROB" error
	$flickr->auth_getToken($_GET['frob']);
	header('Location: flickr.php');
	exit();
}
$result = $flickr->sync_upload('test.png', 'adasd', 'ádsads', 'david walsh, php, mootools, dojo, javascript, css');
//function upfile_flick($url,$title,$description=''){
//    $api_key    = '2e4e72a03aa4db503bfe128e4b4b20e6';
//    $api_secret = '7a7efe62bce5d84e';
//    $flickr = new phpFlickr($api_key,$api_secret, true);
//    $result = $flickr->sync_upload($url, $title, $description, "$title,$description,Tin tức cập nhật, Tin tức online 24h,vnupdate.net");
//    $response = json_decode(file_get_contents('http://api.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key='.$api_key.'&photo_id='.$result.'&format=json&nojsoncallback=1'),0);
//    return 'farm'.$response->photo->farm.'.staticflickr.com/'.$response->photo->server.'/'.$response->photo->id.'_'.$response->photo->secret.'.'.$response->photo->originalformat;
//}
?>